//
//  OtherViewController.m
//  TenThousand
//
//  Created by 我的 on 16/6/20.
//  Copyright © 2016年 baixue. All rights reserved.
//

#import "OtherViewController.h"
#import "MineViewController.h"
#import "SecurityViewController.h"

#import "CurrentVersionViewController.h"//当前版本

@interface OtherViewController ()<UITableViewDelegate,UITableViewDataSource>

@end

#define textLable @[@"关于我们",@"安全保障",@"帮助中心",@"检测升级",@"客服电话"]

@implementation OtherViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    self.navigationItem.title = @"萬元富";
    self.view.backgroundColor = [UIColor colorWithRed:0.95 green:0.95 blue:0.95 alpha:1.00];
    [self myTableView];
}

//创建tableView
- (UITableView *)myTableView{
    _myTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, Screen_Width, Screen_Height-49) style:UITableViewStylePlain];
    _myTableView.delegate = self;
    _myTableView.dataSource = self;
    _myTableView.backgroundColor = [UIColor colorWithRed:0.95 green:0.95 blue:0.95 alpha:1.00];
    _myTableView.showsVerticalScrollIndicator = NO;
    [self.view addSubview:_myTableView];
    
    return _myTableView;
}

//返回5组
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    
    return 5;
}

//每组1行
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 1;
}

//每行40高度
- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 50;
}

//cell复用
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"CELLID"];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"CELLID"];
    }
    
    if (indexPath.section == 4) {
        cell.detailTextLabel.text = @"400-139-3399";
        cell.detailTextLabel.font = [UIFont systemFontOfSize:17.0f];
        
    }else{
        
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    }
    cell.textLabel.text = textLable[indexPath.section];
    cell.textLabel.textColor = [UIColor colorWithRed:0.56 green:0.56 blue:0.58 alpha:1.00];
    cell.textLabel.font = [UIFont systemFontOfSize:17.0f];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.backgroundColor = [UIColor whiteColor];

    return cell;

}

//每组的头部高度为10
- (CGFloat) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 10;
}

//最后一组的footer高度
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    
    if (section == 4) {
         return 30;
    }
    return 0;
}

//添加footer
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    
    if (section == 4) {
        UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, Screen_Width, 30)];
        UILabel *lable = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, Screen_Width-10, 30)];
        lable.text = @"客服工作时间:9:00-21:00";
        lable.font = [UIFont systemFontOfSize:12.00f];
        lable.textAlignment = NSTextAlignmentRight;
        lable.textColor = [UIColor colorWithRed:0.56 green:0.56 blue:0.58 alpha:1.00];
        [view addSubview:lable];
        return view;

    }
    return nil;
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    switch (indexPath.section) {
        case 0:{
            MineViewController *mineView = [[MineViewController alloc] init];
            mineView.num = indexPath.section;
            [self.navigationController pushViewController:mineView animated:YES];
        }
            break;
            
        case 1:{
            SecurityViewController *securityView = [[SecurityViewController alloc] init];
            self.myTableView.backgroundColor = [UIColor whiteColor];
            self.view.backgroundColor = [UIColor whiteColor];
            securityView.hidesBottomBarWhenPushed = YES;
            [self.navigationController pushViewController:securityView animated:YES];
             _myTableView.backgroundColor = [UIColor colorWithRed:0.95 green:0.95 blue:0.95 alpha:1.00];
            
        }
            break;
        case 2:{
            MineViewController *mineView = [[MineViewController alloc] init];
            mineView.num = indexPath.section;
            [self.navigationController pushViewController:mineView animated:YES];
        }
            break;
            
        case 3:{
            CurrentVersionViewController *Version = [[CurrentVersionViewController alloc] init];
            Version.hidesBottomBarWhenPushed = YES;
            [self.navigationController pushViewController:Version animated:YES];
        }
            break;
            
        default:
            break;
    }
    }

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
